package com.bsoft.gol.hcs.specialist.dao;

/**
 * @Author:FangZhiyi
 * @Description
 * @Data Created in 2020/7/15 9:49
 * @Moddified By:
 */

import ctd.persistence.annotation.DAOMethod;
import ctd.persistence.annotation.DAOParam;
import ctd.persistence.support.hibernate.HibernateSupportDelegateDAO;
import ctd.spring.boot.annotation.SsdevDao;
import ctd.util.annotation.RpcService;
import hcn.specialist.DocTeamDiseaseEntity;

import java.util.List;

@SsdevDao( serviceId = "docTeamDiseaseDAOService")
public abstract class DocTeamDiseaseDAO extends HibernateSupportDelegateDAO<DocTeamDiseaseEntity> {

    @RpcService
    @DAOMethod(sql = " from  DocTeamDiseaseEntity where medical_team_id =:teamId ")
    public abstract List<DocTeamDiseaseEntity> queryDocTeamDiseaseList(@DAOParam("teamId")Long teamId);

    @RpcService
    public  DocTeamDiseaseEntity saveDocTeamDiseaseEntity(DocTeamDiseaseEntity docTeamDiseaseEntity){
        return this.save(docTeamDiseaseEntity);
    }

    @RpcService
    @DAOMethod(sql = "DELETE from DocTeamDiseaseEntity where medical_team_id =:teamId ")
    public abstract void deleteDiseaseByTeamId(@DAOParam("teamId")Long teamId);


    @DAOMethod(sql = "select DISTINCT chronicDiseaseId from DocTeamDiseaseEntity where medical_team_id in:teamId ")
    public abstract List<String> findChronicDiseaseId(@DAOParam("teamId")List<Long> teamId);

    @RpcService
    @DAOMethod(sql = "DELETE from DocTeamDiseaseEntity where medical_team_id =:teamId and chronicDiseaseId in:chronicDiseaseIdList")
    public abstract void deleteDiseaseByChronicDiseaseIdList(@DAOParam("teamId")Long teamId, @DAOParam("chronicDiseaseIdList")List<String> chronicDiseaseIdList);

    @RpcService
    @DAOMethod(sql = " select medicalTeamId from DocTeamDiseaseEntity where chronicDiseaseId =:chronicDiseaseId ")
    public abstract List<Long> queryMedicalTeamIdList(@DAOParam("chronicDiseaseId")String chronicDiseaseId);
}
